package com.examples.demo3;

import com.google.inject.Guice;
import com.google.inject.Inject;
import lombok.val;

/**
 * 一个接口有多个实现，
 * 注入到静态变量
 */
public class StaticMultiInterfaceServiceDemo {
    @Inject
    @WWW
    private static Service wwwService;
    @Inject
    @Home
    private static Service homeService;

    public static void main(String[] args) {
        val misd = Guice.createInjector(binder -> {
                    binder.bind(Service.class).annotatedWith(WWW.class).to(WWWService.class);
                    binder.bind(Service.class).annotatedWith(Home.class).to(HomeService.class);
                    binder.requestStaticInjection(StaticMultiInterfaceServiceDemo.class);
                }
        ).getInstance(StaticMultiInterfaceServiceDemo.class);
        StaticMultiInterfaceServiceDemo.homeService.execute();
        StaticMultiInterfaceServiceDemo.wwwService.execute();
    }
}
